import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

import "element-ui/lib/theme-chalk/index.css";
import "@/assets/scss/index.scss";
import http from "@/api/config";
import "./mock";
import ElementUI from "element-ui";

Vue.use(ElementUI);

Vue.prototype.$http = http;
Vue.config.productionTip = false;

router.beforeEach((to, from, next) => {
  console.log(to.path);
  let val = {
    path: to.path,
    name: to.name,
    label: to.meta.label,
    icon: to.meta.icon
  };
  store.commit("selectMenu", val);
  next();
});

// eslint-disable-next-line no-unused-vars
router.afterEach((to, from, next) => {
  console.log(to.matched);
  store.commit("setCrumbList", to.matched);
});

new Vue({
  router,
  store,
  render: h => h(App),
  created() {
    store.commit("addMenu", router);
  }
}).$mount("#app");
